#pragma once
#include "common.h"
#include <vector>

#ifdef OS_LINUX
#include <sys/epoll.h>
#endif

#ifdef OS_MACOS
#include <sys/event.h>
#endif

class Poller {
 public:
  DISALLOW_COPY_AND_MOVE(Poller);
  Poller();
  ~Poller();

  void UpdateChannel(Channel *ch) const;
  void DeleteChannel(Channel *ch) const;

  std::vector<Channel *> Poll(long timeout = -1) const;

 private:
  int m_fd;

#ifdef OS_LINUX
  struct epoll_event *m_events{nullptr};
#endif

#ifdef OS_MACOS
  struct kevent *m_events;
#endif
};
